home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1997 August / Walnut Creek CDROM.7z / VOL_400 / 460_01 / YACL0160.ZIP / uidemo / scroll / appwin.cxx next >
Encoding:
C/C++ Source or Header  |  1996-05-04  |  1.3 KB  |  49 lines

  1.  
  2. #include "appwin.h"
  3. #include "ui/cntroler.h"
  4.  
  5. #define ID_BAR    10
  6. #define ID_LABEL  11
  7. #define ID_BTN    12
  8.  
  9. typedef CL_Binding0<AppWindow> Bind;
  10.  
  11. #if defined(__GNUC__)
  12. template class CL_Binding0<AppWindow>;
  13. #endif
  14.  
  15. AppWindow::AppWindow()
  16. : UI_Dialog (NULL, NULL, UI_Rectangle (100, 100, 270, 260))
  17. {
  18.     _btn   = new UI_ToggleButton (this, UI_Rectangle (10, 10, 150, 25),
  19.                                   ID_BTN);
  20.     _msg   = new UI_Label (this, UI_Rectangle (10, 90, 120, 20), ID_LABEL);
  21.     _bar   = new UI_VScrollBar (this, UI_Rectangle (150, 35, 16, 180), ID_BAR);
  22.     _bar->Range() = CL_Interval (0, 255);
  23.     Bind bind (this, &AppWindow::_DoScroll);
  24.     _bar->ClientSet().Add (bind);
  25.     CL_Interval init (26, 50); // Initial setting
  26.     _bar->Model() = init;
  27.     _msg->Model() = init.AsString();
  28.     _btn->Model() = CL_Integer ((short) TRUE);
  29.     _btn->Title() = "Smooth scroll";
  30. }
  31.  
  32. bool AppWindow::_DoScroll ()
  33. {
  34.     CL_String& s = (CL_String&) _msg->Model();
  35.     s = _bar->Model().AsString();
  36.     _Controller->GiveFocusTo (_bar);
  37.     return TRUE;
  38. }
  39.  
  40.  
  41. bool AppWindow::HandleChildEvent (const UI_Event& e)
  42. {
  43.     if (e.Origin()->ViewID() !=  ID_BTN || e.Type() != Event_Select)
  44.         return FALSE;
  45.     CL_Integer& v = (CL_Integer&) (e.Origin()->Model());
  46.     _bar->SmoothScroll() = v.Value();
  47.     return TRUE;
  48. }
  49.